package com.logicwin.aibala.model.swUpdate;

/**
 * 描述程序版本信息结构体
 * 
 * @author GuoDing
 * @since 2011-05-26
 */
public final class SWVersion {
	//主版本号
	private int main_version;  
	
	//次版本号
	private int sub_version;
	
	//是否该版本强制用户升级
	private boolean isForced;
	
	public SWVersion(int main, int sub, boolean forced) {
		this.main_version = main;
		this.sub_version = sub;
		this.isForced = forced;
	}
	
	/**
	 * 获取主版本号
	 * @return
	 */
	public int getMainVersion() {
		return this.main_version;
	}
	
	/**
	 * 获取次版本号
	 * @return
	 */
	public int getSubVersion() {
		return this.sub_version;
	}
	
	/**
	 * 是否需要强制升级
	 * @return
	 */
	public boolean isForcedUpdate() {
		return this.isForced;
	}
	
	/**
	 * 是否比被比较的版本旧
	 * @param newVersion
	 * @return
	 */
	public boolean isOlder(SWVersion newVersion) {
		if(newVersion.getMainVersion() > this.main_version) {
			return true;
		}
		else if(newVersion.getMainVersion() == this.main_version) {
			return (newVersion.getSubVersion() > this.sub_version);
		}
		return false;
	}
	
}



